<?php
/**
 * @author spenceryg
 * @date 2022/11/25
 * @time 12:55 下午
 * @focus love & life
 */

namespace app\admin\controller\sys\model;

use think\Model;

class AdminNodeModel extends Model
{
    use \app\common\traits\model\ModelTreeTrait;
    protected $name = 'admin_node';
    protected $table = 'db_admin_node';
    /**
     * href获取器
     * @param $value
     * @return string
     */
    public function getHrefAttr($value): string
    {
        return (string)url($value);
    }

    /**
     * pid获取器
     * @param $value
     * @return mixed|string
     */
    public function getPidAttr($value)
    {
        return $value == 0 ? '顶级' : $this->where('pid', $value)->value('name');
    }
}
